<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><spring:message  code="pim"/> - <spring:message  code="manage.employees"/></title>
<link href="<%= request.getContextPath() %>/css/custom.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/v.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/paging.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/jquery.ui.dialog.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.6.2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-ui-1.8.14.custom.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.hint.text.js"></script>
<%@include file="script/pim-util.jsp" %>
<%@include file="script/paging-script.jsp" %>
<%@include file="script/employee-script.jsp" %>
<script type="text/javascript">
jQuery(document).ready(function(){    
    $('input[title]').inputHints();	
});   
</script>
<style type="text/css">
.logo,.logo img{
height: 150px !important;
width: 150px !important;
}
.new-manage-org-dot-line{
width: 100% !important;
}
</style>
</head>
<body>
<% try{ %>
<c:if test="${bean.isSigned == true}">
<div id="all">
<div id="wrapper">
<div id="mainheader">
	<jsp:include page="include/common/headerSignedIn.jsp" />
</div> 
<div id="content-wrapper">
<div id="top-menu">
     <jsp:include page="include/common/topMenuHome.jsp" />
</div>
<div id="dialogDeleteEmployee"></div>
<form:form action="" method="post" name="frmEmployees" commandName="employeeQuery">
<div class="v-row" style="padding-top: 20px;">	    
   <div class="v-row-right"> 	
       <form:input maxlength="50" cssClass="new-manage-org-search txt-search"  path="searchKey" 
          cssStyle="margin-right: 10px;" title="Keyword..."/>
       <input type="button" class="bt-form" id="searchEmployees" style="margin-right: 10px;" value='<spring:message  code="search"/>'>
	</div>	   
</div>	
							
<div><b style="margin-left: 10px;" class="v-title"><spring:message  code="listOfEmployees"/></b></div>

<div class="new-manage-org-dot-line"></div>		

<c:choose>
<c:when test="${bean.countList == 0 && employeeQuery.searchKey != ''}">
	<div class="new-manage-org-list-content" style="margin-right: 18px;">
		<span style="margin-left: 10px;"><spring:message  code="search.empty"/></span>
	</div>
</c:when>		
<c:otherwise>
<c:if test="${bean.isAdmin == true}">
	<div align="right" class="new-manage-org-action-head">
		<a class="new-manage-org-link" 
		   href="handleEmployee.htm?cmd=add"> + <spring:message  code="add.employee"/></a>
		   &nbsp;|&nbsp;
		<a class="new-manage-org-link" onClick="deleteEmployees()"
		   href="javascript:void(0);"><spring:message  code="delete.employee"/></a>   
	</div>
</c:if>	
		
<div class="v-row">
     <c:forEach items="${bean.employees}" var="employee">
		<ul style="list-style-type: none;float: left;">
		<li>			
	       <c:if test="${bean.isAdmin == true}">
			<div class="new-manage-org-checkOrg" style="padding-right: 10px;">										
			   <form:checkbox path="employeeIds" value="${employee.employeeid}" cssClass="ckbChild"/>										
			</div>
		    </c:if>
		    						
		   <div style="float: left;padding-right: 10px;">				    
		     <c:set value="${fn:trim(employee.imageurl)}" var="imageurl" />
				<c:choose>
				<c:when test="${imageurl == null || imageurl == ''}">
					<div class="logo" align="center">
						<img alt="" src="/pim/images/small_noImage.gif"/>
					</div>
				</c:when>
				<c:otherwise>
					<div class="logo" align="center">
						 <img alt="" src="${imageurl}"/>
					</div>
				</c:otherwise>
				</c:choose>
		   </div>
		   <div style="float: right; width: 245px;">
		      <span><spring:message  code="employee.fullname"/> : ${employee.lastname} ${employee.firstname}</span><br/>
		      <span><spring:message  code="employee.visa"/> : ${employee.visa}</span>
		      &nbsp;
		      <c:if test="${bean.isAdmin == true || bean.visa == employee.visa}">
				  <span class="v-bt-edit">
					  <a href="handleEmployee.htm?id=${employee.employeeid}&cmd=edit" 
					      class="v-link" ><spring:message code="button.edit" />
					   </a>
				  </span>						  
              </c:if>
		      <br/>				    
		      <span><spring:message  code="employee.rank"/> : ${employee.rank.name}</span><br/>				      
		      <span><spring:message  code="employee.email"/> : ${employee.email}</span><br/>
		      <span><spring:message  code="employee.cellphone"/> : ${employee.phone}</span>
		   </div>									
		 </li>
		</ul>
	</c:forEach>
</div>
</c:otherwise>		
</c:choose>

<c:if test="${bean.total > bean.itemsPerPage}">
    <div id="paging" class="productView-paging" style="padding:20px;">		
			<c:set value="${bean.paging}" var="paging"></c:set>
			<%@ include file="include/common/pagination.jsp"%>		
    </div>
</c:if>

<input type="hidden" name="cmd"/>
</form:form>	
</div>
</div>
<div class="footer">
    <jsp:include page="include/common/footer.jsp" />
</div>
</div>
</c:if>
<% } catch(RuntimeException re){ re.printStackTrace(); } %>
</body>
</html>